﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using System.Linq;
using System.Web;
using LunchCommand.Models;
using LunchCommand.Models.Logging;

namespace LunchCommand.Data
{
    public class LunchCommandContext : DbContext
    {
        public LunchCommandContext()
            : base("DefaultConnection")
        {

        }

        public IDbSet<Venue> Venues { get; set; }

        public IEnumerable<Venue> ActiveVenues
        {
            get
            {
                return this.Venues.Where(v => !v.Deleted);
            }
        }

        public IDbSet<Genre> Genres { get; set; }

        public IDbSet<User> Users { get; set; }

        public IDbSet<Lunch> Lunches { get; set; }

        public IDbSet<LogEntry> LogEntries { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        }
    }
}